package Singleton;

public class SingletonInner {
	
	private SingletonInner(){
		System.out.println("SingletonInner");
	}
	
	//通过内部内创建单例，可以延迟创建和不用像写线程那么不优雅
	private static class SingletonHoledr{
		private static SingletonInner instance = new SingletonInner();
		
		static{
			System.out.println("SingletonHoledr");
		}
		public SingletonHoledr(){
			System.out.println("SingletonHoledr");
		}
	}
	
	public static SingletonInner getInstance(){
		return SingletonHoledr.instance;
	}
	@Override
	protected void finalize() throws Throwable {
		System.out.println("finalize");
	}
	public static void main(String[] args) {
		System.out.println("begin");
		SingletonInner.getInstance();
		
		System.out.println("end");
	}
}
